import { Vector3, Spherical } from "../three.module.js";

//立方体
export default class Sphere {
    constructor(r = 0.1) {
        this.r = r;

        this.normals = [];//顶点法向
        this.vertices = [];//顶点信息
        this.elements = [];//默认的Elements
        this.elementsOfLine = [];//默认的线框Elements
        this.count = 0;

        this._init();
    }

    _init() {
        const { r } = this;
        this.count = 8;

        this.vertices = [
            -r, r, -r,
            -r, r, r,
            r, r, r,
            r, r, -r,
            -r, -r, -r,
            -r, -r, r,
            r, -r, r,
            r, -r, -r,
        ];

        this.elements = [
            0, 1, 2, 0, 2, 3,
            1, 5, 6, 1, 6, 2,
            5, 4, 7, 5, 7, 6,
            4, 0, 3, 4, 3, 7,
            2, 6, 7, 2, 7, 3,
            0, 4, 5, 0, 5, 1,
        ];

        this.elementsOfLine = [
            0, 1, 1, 2, 2, 3, 3, 0,
            4, 5, 5, 6, 6, 7, 7, 4,
            0, 4, 1, 5, 2, 6, 3, 7,
        ];

        this.normals = [
            -1, 1, -1,
            -1, 1, 1,
            1, 1, 1,
            1, 1, -1,
            -1, -1, -1,
            -1, -1, 1,
            1, -1, 1,
            1, -1, -1,
        ];
    }

    //获取线框的Elemenets
    getElementsOfLine() {
        return this.elementsOfLine;
    }

}